/*******************************************************************************
	
	AgentGame v1.0.
	Copyright Peter Eredics (BUTE-DMIS) 2010-2011.
	
	simple.asl - Simple agent running for the closest food it sees 
	
*******************************************************************************/


// No initial beliefs yet
started.

+time(_): started <-
	-started;
	setcolor(0,255,255).

+!error: simplelab.Error
    .
-!error: simplelab.Error
    .

+time(_): simplelab.Action(A,B,C) <-
	!act(A,B,C).
	//debug.DebugAction.
	
// Stepping
+!act(A,B,C) : A == 0 <-
	step(B).
	
// Turning
+!act(A,B,C) : A == 1 <-
	turn(B).	
	
// Waiting
+!act(A,B,C) : A == 2 <-
	wait.	

+!act(A,B,C) : A == 3 <-
	eat.
-!act(A,B,C) : A == 3  <-
    !error.	
-!act : A == 0 & simplelab.ErrorBlock.
	
	
// ... and turn back when reaching the wall
+time(_): mydir(D) & D < 2 <-
	turn(D+2).
	//debug.DebugAction.

+time(_): mydir(D) & D >= 2 <-
	turn(D-2).
	//debug.DebugAction.
	